﻿@model IEnumerable<Eqwww.Domain.Models.SystemManage.OrganizeModel>

@{
    ViewData["Title"] = "Index";
    Layout = "~/Views/Shared/_ManageIndexLayout.cshtml";
}

<div id="eq-operate-organize" class="eq-operation">
    <div class="mdui-appbar mdui-appbar-fixed mdui-color-white mdui-shadow-1">
        <div class="mdui-toolbar">
            <a class="eq-operate-cancel-select" href="javascript:;" mdui-tooltip="{content: '取消选择'}">
                已选中 <b>1</b> 项
            </a>
            <module-buttons class="mdui-btn-group mdui-hidden-sm-down" buttons="@ViewBag.SelectedButtons"></module-buttons>
            <module-buttons class="mdui-hidden-md-up" buttons="@ViewBag.SelectedButtons" is-float="true"></module-buttons>
            <div class="mdui-toolbar-spacer"></div>
            <a class="eq-operate-cancel-select mdui-btn mdui-ripple" href="javascript:;">
                <i class="mdui-icon material-icons">do_not_disturb</i> 取消
            </a>
        </div>
    </div>
</div>
<div id="eq-operate-post" class="eq-operation">
    <div class="mdui-appbar mdui-appbar-fixed mdui-color-white mdui-shadow-1">
        <div class="mdui-toolbar">
            <a class="eq-operate-cancel-select" href="javascript:;" mdui-tooltip="{content: '取消选择'}">
                已选中 <b>1</b> 项
            </a>
            <module-buttons class="mdui-btn-group mdui-hidden-sm-down" buttons="@ViewBag.SelectedPostButtons"></module-buttons>
            <module-buttons class="mdui-hidden-md-up" buttons="@ViewBag.SelectedPostButtons" is-float="true"></module-buttons>
            <div class="mdui-toolbar-spacer"></div>
            <a class="eq-operate-cancel-select mdui-btn mdui-ripple" href="javascript:;">
                <i class="mdui-icon material-icons">do_not_disturb</i> 取消
            </a>
        </div>
    </div>
</div>
<div id="eq-operate-user" class="eq-operation">
    <div class="mdui-appbar mdui-appbar-fixed mdui-color-white mdui-shadow-1">
        <div class="mdui-toolbar">
            <a class="eq-operate-cancel-select" href="javascript:;" mdui-tooltip="{content: '取消选择'}">
                已选中 <b>1</b> 项
            </a>
            <module-buttons class="mdui-btn-group mdui-hidden-sm-down" buttons="@ViewBag.SelectedUserButtons"></module-buttons>
            <module-buttons class="mdui-hidden-md-up" buttons="@ViewBag.SelectedUserButtons" is-float="true"></module-buttons>
            <div class="mdui-toolbar-spacer"></div>
            <a class="eq-operate-cancel-select mdui-btn mdui-ripple" href="javascript:;">
                <i class="mdui-icon material-icons">do_not_disturb</i> 取消
            </a>
        </div>
    </div>
</div>

<div class="mdui-appbar mdui-shadow-1 mdui-color-white">
    <div class="mdui-toolbar">
        <a id="refreshBtn" class="eq-operate-cancel-select mdui-btn mdui-ripple mdui-ripple-black" href="javascript:;">
            <i class="mdui-icon material-icons">refresh</i> 刷新
        </a>
        <div class="mdui-toolbar-spacer"></div>
        <module-buttons class="mdui-btn-group" buttons="@ViewBag.InitialButtons"></module-buttons>
    </div>
</div>

<div class="mdui-container mdui-m-t-3 mdui-m-b-3">
    <div class="mdui-table-fluid">
        <table class="mdui-table eq-list-table">
            <thead>
                <tr>
                    <th></th>

                    <th>
                        @Html.DisplayNameFor(model => model.Name)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.Code)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.OrganizeType)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.OrganizeBelongType)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.SortCode)
                    </th>

                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr data-id="@item.Id"  data-layer="@item.Layer">
                        <td>
                            @if (Model.Any(x => x.ParentId == item.Id))
                            {
                                <i class="mdui-icon material-icons">arrow_drop_down</i>
                            }
                        </td>
                        <td>
                            @for (int i = 0; i < item.Layer; i++)
                            {
                                <text>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</text>
                            }
                            @Html.DisplayFor(modelItem => item.Name)
                        </td>
                        <td>@Html.DisplayFor(modelItem => item.Code)</td>
                        <td>@Html.DisplayFor(modelItem => item.OrganizeType)</td>
                        <td>@Html.DisplayFor(modelItem => item.OrganizeBelongType)</td>
                        <td>@Html.DisplayFor(modelItem => item.SortCode)</td>
                        
                    </tr>
                }
            </tbody>
        </table>
    </div>

</div>

@section Scripts {
    <script>
        
        $(function () {
                //$('.eq-list-table').eqTable();

                $('#refreshBtn').bind('click', function () {
                    top.$.loading(false);
                    window.location.reload();
                });
        });

        function btn_create() {

            $.modalOpen({
                id: 'formCreate',
                title: '新建组织',
                url: '/SystemManage/Organize/Create',
                width: '100%',
                height: '100%',
                callBack: function (iframeId) {
                    top.frames[iframeId].submitForm();
                }
            });
            return false;
        }

        function btn_edit() {
            var key = $('.eq-list-table').GridSelectedKey();
            
            if (!key) {
                $.modalMessage('未选中任何行！');
                return false;
            }
            
            $.modalOpen({
                id: 'formEditButton',
                title: '修改组织',
                url: '/SystemManage/Organize/Edit?id=' + key,
                width: '100%',
                height: '100%',
                callBack: function (iframeId) {
                    top.frames[iframeId].submitForm();
                }
            });
        }

        function btn_details() {
            var key = $('.eq-list-table').GridSelectedKey();
            if (!key) {
                $.modalMessage('未选中任何行！');
                return false;
            }
            $.modalOpen({
                id: 'Details',
                title: '查看组织',
                url: '/SystemManage/Organize/Details?id=' + key,
                width: '100%',
                height: '100%',
                isback: true,
                hideConfirmBtn: true,
                btn: null
            });
        }

        function btn_delete() {
            var key = $('.eq-list-table').GridSelectedKey();
            if (!key) {
                $.modalMessage('未选中任何行！');
                return false;
            }
           
            $.deleteForm({
                url: '/SystemManage/Organize/Delete',
                param: { id: key },
                success: function (iframeId) {
                    window.location.reload();

                }
            })
        }
    </script>
}
